const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = {
  target: 'web',
  context: path.resolve(__dirname, './src'),
  entry: {
    app: './js/app.js',
    'bpmn-app': './js/bpmn-js/bpmn-app.js'
  },
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: '[name].bundle.js',
    publicPath: '/'
  },
  module: {
    rules: [{
        test: /\.css$/,
        use: 'css-loader'
      },
      {
        test: /\.(js|jsx)$/,
        use: 'babel-loader'
      },
      {
        test: /\.bpmn$/,
        use: 'raw-loader'
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './index.html',
      chunks: ['app']
    }),
    new HtmlWebpackPlugin({ // Also generate a test.html
      filename: 'bpmn-js.html',
      template: './bpmn-js.html',
      chunks: ['bpmn-app']
    }),
    new CopyWebpackPlugin([{
      from: 'lib',
      to: 'lib'
    }
    ])
  ],
  devtool: 'source-map',
  devServer: {
    contentBase: path.join(__dirname, 'dist'),
    port: 8081
  }
}
